<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1>Create List</h1>

  <ul id="ul">
    
  </ul>

  <script>
    let liList = []
    let userText
    do {
      userText = prompt('请输入')
      if (userText) {
        let li = document.createElement('li')
        userText && li.append(userText)
        liList.push(li)
      }
    } while (userText)

    console.log(liList)
    ul.append(...liList)
  </script>

  <script>
    /* let ul = document.createElement('ul');
    document.body.append(ul);

    while (true) {
      let data = prompt("Enter the text for the list item", "");

      if (!data) {
        break;
      }

      let li = document.createElement('li');
      li.textContent = data;
      ul.append(li);
    } */
  </script>
</body>
</html>